package com.gavindon.android.repo

import com.gavindon.android.base.BaseRepository
import com.gavindon.android.entity.CheckCanLookResp
import com.gavindon.android.entity.ComboResp
import com.gavindon.android.entity.StudyRecordResp
import com.gavindon.android.network.DataResult

/**
 * description: 多个页面使用的API
 * Created by liNan on  2022-2-11 09:17
 */
class CommonRepo : BaseRepository() {

    /*是否收藏*/
    suspend fun requestCollectStatus(id: String): DataResult<Boolean> {
        return launchRequest {
            service.clientFavoriteStatus(id)
        }
    }

    /*添加收藏*/
    suspend fun requestCollectAdd(id: String): DataResult<String> {
        return launchRequest {
            service.clientFavoriteAdd(id)
        }
    }

    /*取消收藏*/
    suspend fun requestCollectCancel(id: String): DataResult<String> {
        return launchRequest {
            service.clientFavoriteCancel(id)
        }
    }

    /*保存课程观看进度*/
    suspend fun pushLessonProgress(lessonId: String, second: Int): DataResult<String> {
        return launchRequest {
            service.clientLessonProgress(lessonId, second)
        }
    }

    /*查询套餐列表*/
    suspend fun queryCombLst(courseId: String): DataResult<List<ComboResp>> {
        return launchRequest {
            service.comboLstByCourseId(courseId)
        }
    }

    //支付完成查看课程或者套餐是否可以观看
    suspend fun payFinish(
        orderType: String,
        packageOrCourseId: String
    ): DataResult<List<CheckCanLookResp>> {
        return launchRequest {
            service.findOrder(orderType, packageOrCourseId)
        }
    }

    suspend fun getStudyRecord(lessonId: String): DataResult<StudyRecordResp> {
        return launchRequest {
            service.clientCourseRcdById(lessonId)
        }
    }
}